<template>
  <div 
  v-loading="loading"
  class="">
   <h2 class="post-title"><i class="el-icon-news"></i> {{post.title}}</h2>

   <div class="post-info">
   <i class="el-icon-time"></i> 创建时间:{{post.create_time|formatDate}} 
   <i class="el-icon-time"></i> 最后更新时间:{{post.edit_time|formatDate}} 
   阅读数量:{{post.read}}</div>
   <Markdown 
   :preview="true"
  v-model="post.content"
  ></Markdown>
  </div>
</template>

<script>
import api from "@/api";
import {unescape} from '@/utils/encoding'
import Markdown from "@/components/Markdown";
import qs from "qs";
export default {
  name: "Post",
  created() {
    this.loading = true;
     api.findPost({id:this.$route.params.id})
      .then(res => {
        this.post = res.data.data;
        console.log(this.post.content)
        this.post.content = unescape(this.post.content);
        this.loading = false;
      });
  },
  components: {
    Markdown
  },
  data() {
    return {
      loading:false,
      post: [{}]
    };
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.post-info{
   background: white;
    /* height: 40px;
    line-height: 40px; */
    padding: 12px;
    
}
.post-title{
background: white;
 padding: 12px;
 border-bottom: 1px solid #ccc;
}
</style>
